from api.reg import RegAPI
from tool import Utils
import pytest
import config


# 创建测试类
class TestReg:
    # 初始化
    def setup_class(self):
        # 创建RegAPI对象
        self.reg = RegAPI()

    # 登录
    @pytest.mark.parametrize("phone,password,status_code,code,msg", Utils().read_json(config.BASE_PATH + "/data/login.json"))
    def test01_login(self, phone, password, status_code, code, msg):
        test_data = {
            "keywords": phone,
            "password": password
        }
        response = self.reg.login(test_data)
        assert response.status_code == status_code
        assert response.json()["status"] == code
        assert msg in response.text
